<?php

use think\migration\Migrator;
use think\migration\db\Column;

class StoreOrderStorage extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $this->table('store_order_storage',['comment' => '订单出库表'])
            ->addColumn('store_order_id', 'integer', ['limit' => 11, "after" => 'id', 'comment' => '订单id'])
            ->addColumn('store_order_detail_id', 'integer', ['limit' => 11, "after" => 'store_order_id', 'comment' => '订单明细id'])
            ->addColumn('company_order_storage_id', 'integer', ['limit' => 11, "after" => 'store_order_detail_id', 'comment' => '进货库存中间表id'])
            ->addColumn('warehouse_storage_id', 'integer', ['limit' => 11, "after" => 'company_order_storage_id', 'comment' => '库位id'])
            ->addColumn('warehouse_storage_name', 'string', ['limit' => 255, "after" => 'warehouse_storage_id', 'comment' => '库位名称'])
            ->addColumn('goods_id', 'integer', ['limit' => 11, "after" => 'warehouse_storage_name', 'comment' => '商品id'])
            ->addColumn('goods_rule_id', 'integer', ['limit' => 11, "after" => 'goods_id', 'comment' => '商品规格id'])
            ->addColumn('quantity', 'integer', ['limit' => 11, "after" => 'goods_rule_id', 'comment' => '数量'])
            ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'after' => 'quantity', 'comment' => '1:正常,2:禁用'])
            ->addColumn('create_time', 'integer', ['limit' => 10, 'after' => 'status', 'default' => 0, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['limit' => 10, 'after' => 'create_time', 'default' => 0, 'comment' => '更新时间'])
            ->addColumn('delete_time', 'integer', ['limit' => 10, 'after' => 'update_time', 'default' => 0, 'comment' => '删除时间'])
            ->create();
    }
}
